<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.prime.com.tr/ui"
        xmlns:finantial="http://java.sun.com/jsf/composite/components/finantial"
        xmlns:c="http://java.sun.com/jsp/jstl/core">



     <p:panel>
         <h:panelGrid id="month_outcome_grid" cellspacing="5" columns="2">
            <finantial:label for="month_outcome_description" value="Descrição:"/>
            <h:inputText required="true" id="month_outcome_description" value="#{financeBean.despesa.description}"/>
            <finantial:label for="month_outcome_data" value="Data:"/>
            <p:calendar id="month_outcome_data" effectDuration="0.5" value="#{financeBean.despesa.date}" pattern="dd/MM/yyyy" effect="drop"  showOtherMonths="true"  readOnlyInputText="true" timeZone="America/Sao_Paulo" locale="pt_BR" navigator="true" styleClass="calendar"  mindate="#{financeBean.firstDayOfMonth}" maxdate="#{financeBean.lastDayOfMonth}"  popupIcon="../resources/images/calendar.png"/>
            <finantial:label for="month_outcome_value" value="Valor:"/>
            <h:inputText id="month_outcome_value" value="#{financeBean.despesa.value}">
                <f:convertNumber pattern="#,###,##0.00" currencyCode="BRL" type="currency"/>
                <f:ajax event="blur" render="@this"/>
            </h:inputText>
            <finantial:label for="month_outcome_subtipo"  value="#{msg['finance.label.subtipo']}:"/>
            <h:selectOneMenu id="month_outcome_subtipo" value="#{financeBean.despesa.type}" styleClass="modalType">
                <f:selectItems value="#{financeBean.subtiposOutcome}" var="subtipo" itemLabel="#{subtipo.description}" itemValue="#{subtipo}"/>
                                    <f:converter converterId="outcomeConveter"/>
                                </h:selectOneMenu>
        </h:panelGrid>
         <div align="center">
         <h:panelGrid columns="2" cellspacing="10">
             <p:commandButton value="salvar"  action="#{financeBean.addMonthOutcome}" async="true" ajax="true"  update="months_form:months_panel,month_outcome_msg" oncomplete="handleAdd(args)"/>
         </h:panelGrid>
         </div>
         <p:messages id="month_outcome_msg"/>
     </p:panel>

    <script type="text/javascript">
    function handleAdd(args){
        if(args.validationFailed == false){
            setTimeout("wait()",1000);
        }
    }

    function wait(){
        monthModal.hide();
    }

</script>
</ui:composition>